<template>
<view>

<view class="user flex">
    <image @tap="toLogin" :src="userInfo&&userInfo.avatar?userInfo.avatar:'/static/images/defaultorg.png'"></image>
    <view class="motto" v-if="loginFlag">
        <view v-if="userInfo">你好，{{userInfo.name}}</view>
       
    </view>
    <view class="motto" v-else>
        <view class="un_login">点击头像登录</view>
    </view>
</view>
<view class="datas flex">
    <view class="data_item">
        <view class="num" v-if="!loginFlag">--</view>
        <view class="num" v-else>{{userInfo.duration}}</view>
        <view class="txt">时长</view>
    </view>
    <view class="data_item">
        <view class="num" v-if="!loginFlag">--</view>
        <view class="num" v-else>{{userInfo.integral}}</view>
        <view class="txt">积分</view>
    </view>
    <view class="data_item">
        <view class="num" v-if="!loginFlag">--</view>
        <view class="num" v-else>{{userInfo.integralTotal}}</view>
        <view class="txt">总积分</view>
    </view>
</view>
<view class="split"></view>
<view @tap="toAct" class="list_item flex">
    <image class="icon" src="/static/images/list_item01.png"></image>
    <view class="txt">已报名的活动</view>
    <image class="arrow" src="/static/images/icon_arrow_gray.png"></image>
</view>
<view class="split"></view>
<view @tap="toService" class="list_item flex">
    <image class="icon" src="/static/images/list_item01.png"></image>
    <view class="txt">已接单</view>
    <image class="arrow" src="/static/images/icon_arrow_gray.png"></image>
</view>
<view class="split"></view>
<view @tap="toOrder" class="list_item flex">
    <image class="icon" src="/static/images/list_item01.png"></image>
    <view class="txt">已点单</view>
    <image class="arrow" src="/static/images/icon_arrow_gray.png"></image>
</view>
<view class="split"></view>
<view @tap="toReserve" class="list_item flex">
    <image class="icon" src="/static/images/list_item01.png"></image>
    <view class="txt">已定场馆</view>
    <image class="arrow" src="/static/images/icon_arrow_gray.png"></image>
</view>
<view class="split"></view>
<view @tap="toOrg" class="list_item flex">
    <image class="icon" src="/static/images/list_item02.png"></image>
    <view class="txt">已加入的组织</view>
    <image class="arrow" src="/static/images/icon_arrow_gray.png"></image>
</view>
<view class="split"></view>
<view @tap="toInfo" class="list_item flex">
    <image class="icon" src="/static/images/list_item03.png"></image>
    <view class="txt">个人资料</view>
    <image class="arrow" src="/static/images/icon_arrow_gray.png"></image>
</view>
<view class="split"></view>
<view @tap="toAboutus" class="list_item flex">
    <image class="icon" src="/static/images/list_item04.png"></image>
    <view class="txt">关于我们</view>
    <image class="arrow" src="/static/images/icon_arrow_gray.png"></image>
</view>
<view class="tips" style="margin-top: 60rpx;">版权所有 © 人人志愿</view>

</view>
</template>

<script>
var a = function (a) {
  return a && a.__esModule ? a : {
    default: a
  };
}(require("../../utils/api.js")),
    t = require("../../utils/request.js"),
    e = require("../../utils/util.js"),
	config = require("../../utils/config.js"),
    app = getApp(),
    o = a.default.volunteerInfo,
	host = config.config.host;

export default {
  data() {
    return {
      loginFlag: !1,
      userInfo: null,
      tabbar: ""
    };
  },

  components: {

  },
  props: {},
  onLoad: function (a) {

  },
  onReady: function () {},
  onShow: function () {
    var a = this,
        t = app.globalData.loginFlag;
        /* var userInfo = uni.getStorageSync("userInfo")
		if(userInfo){
			this.setData({userInfo:userInfo,loginFlag:1})
			app.globalData.zyzId = userInfo.id
			uni.stopPullDownRefresh();
			return
		} */
    this.setData({
      loginFlag: t
    }), t ? this.getVolunteerInfo().then(function (t) {
      if (t.data.success) {
        var n = t.data.data;
        n.avatar = n.avatar ? n.avatar.split("?")[0] + "?imageView2/2/w/210/h/210" : "/static/images/defaultorg.png", a.setData({
          userInfo: t.data.data
        });
      } else uni.switchTab({
        url: "/pages/index/index"
      });
    }).catch(function (a) {
      console.log(a);
    }) : this.setData({
      userInfo: null
    });
  },
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {
    var a = this;
    this.loginFlag ? this.getVolunteerInfo().then(function (t) {
      if (t.data.errCode === e.ERR_OK) {
        var n = t.data.data;
        n.avatar = n.avatar ? n.avatar.split("?")[0] + "?imageView2/2/w/210/h/210" : "/static/images/defaultorg.png", a.setData({
          userInfo: t.data.data
        }), uni.stopPullDownRefresh();
      } else uni.switchTab({
        url: "/pages/index/index"
      });
    }).catch(function (a) {
      console.log(a);
    }) : uni.stopPullDownRefresh();
  },
  onReachBottom: function () {},
  onShareAppMessage: function () {
    return {
      title: "让公益更生活 让生活更公益",
      path: "/pages/index/index",
      imageUrl: "/static/images/zyh_logo.jpg"
    };
  },
  methods: {
    toLogin: function () {
      this.loginFlag || uni.navigateTo({
        url: "/pages/entry/login"
      });
    },
    getVolunteerInfo: function () {
      var a = {
        data: {
					api: o,
          id: app.globalData.zyzId,
					contentType: 'application/x-www-form-urlencoded'
        }
      };
      return (0, t.request)(a, "normal", !0);
    },
    makePhoneCall: function () {
      uni.makePhoneCall({
        phoneNumber: "4000035125"
      });
    },
    toAct: function () {
      this.loginFlag ? uni.navigateTo({
        url: "/pages/me/act/act"
      }) : uni.showToast({
        title: "请先登录",
        icon: "none"
      });
    },
	toService: function () {
	  this.loginFlag ? uni.navigateTo({
	    url: "/pages/me/service/service"
	  }) : uni.showToast({
	    title: "请先登录",
	    icon: "none"
	  });
	},
	toOrder: function () {
	  this.loginFlag ? uni.navigateTo({
	    url: "/pages/me/order/orderlist"
	  }) : uni.showToast({
	    title: "请先登录",
	    icon: "none"
	  });
	},
	toReserve: function () {
	  this.loginFlag ? uni.navigateTo({
	    url: "/pages/me/reserve/reserve"
	  }) : uni.showToast({
	    title: "请先登录",
	    icon: "none"
	  });
	},
    toOrg: function () {
      this.loginFlag ? uni.navigateTo({
        url: "/pages/org/detail?id=" + this.userInfo.orgId
      }) : uni.showToast({
        title: "请先登录",
        icon: "none"
      });
    },
    toInfo: function () {
      if (this.loginFlag) {
        var a = this.userInfo;
        uni.navigateTo({
          url: "/pages/me/info/info?name=" + a.name + "&cardType=" + a.cardType + "&idcard=" + a.cardNum + "&mobile=" + a.mobile
        });
      } else uni.showToast({
        title: "请先登录",
        icon: "none"
      });
    },
    toAboutus: function () {
      uni.navigateTo({
        url: "/pages/tmp/webview?linkUrl=" + encodeURIComponent(host+"/aboutUs") + "&linkLogin=0"
      });
    }
  }
};
</script>
<style>
page {
    width: 100%;
    height: auto;
    min-height: 100%;
    overflow: auto;
    background: #f4f4f4;
}

.user {
    justify-content: flex-start;
    width: 100%;
    height: 140rpx;
    padding: 20rpx 30rpx 0;
    background: #fff;
}

.user image {
    flex: 0 0 120rpx;
    width: 120rpx;
    height: 120rpx;
    margin-right: 20rpx;
    border-radius: 50%;
}

.user .motto {
    flex: auto;
    height: 120rpx;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-content: center;
}

.user .motto view:nth-child(1) {
    margin-bottom: 20rpx;
    font-size: 36rpx;
}

.user .motto view:nth-child(2) {
    font-size: 24rpx;
    color: #666;
}

.user .motto view.un_login {
    margin: 0;
    font-size: 28rpx;
    color: #999;
}

.datas {
    width: 100%;
    height: 172rpx;
    justify-content: space-around;
    background: #fff;
}

.data_item {
    flex: auto;
    text-align: center;
    padding-top: 40rpx;
    padding-bottom: 64rpx;
}

.data_item .num {
    margin-bottom: 12rpx;
    font-size: 30rpx;
    font-weight: 600;
}

.data_item .txt {
    font-size: 24rpx;
    color: #666;
}

.list_item {
    width: 100%;
    height: 132rpx;
    justify-content: flex-start;
    background: #fff;
    padding: 0 30rpx;
}

.list_item .icon {
    flex: 0 0 40rpx;
    width: 40rpx;
    height: 40rpx;
    margin-right: 28rpx;
}

.list_item .txt {
    flex: auto;
    height: 132rpx;
    line-height: 132rpx;
    text-align: left;
    font-size: 30rpx;
    color: #333;
}

.list_item .arrow {
    flex: 0 0 16rpx;
    width: 16rpx;
    height: 24rpx;
    margin-right: 32rpx;
}

.tips {
    text-align: center;
    line-height: 34rpx;
    font-size: 24rpx;
    color: #b4b4b4;
}
</style>